public class demo01_EvenTimesOddTime {

    public static void printOddTimesNum1(int[] arr) {
        int eor = 0;
        for (int i = 0; i < arr.length; i++) {
            eor = eor ^ arr[i];

        }
        System.out.println(eor);
    }

    public static void printOddTimesNum2(int[] arr) {
        int eor = 0;

        for (int i = 0; i < arr.length; i++) {
            eor = eor ^ arr[i];

        }
        //eor = a ^ b
        // eor != 0
        // eor必有一位 1
        int rightOne  = eor & (~eor + 1); //取出最右的1
        int onlyOne = 0;
        for (int cur : arr) {
            if ((cur & rightOne) == 0) {
                onlyOne ^= cur;
            }
        }

        System.out.println(onlyOne + " " + (eor ^ onlyOne));
    }


    public static void main(String[] args) {
        int[] arr = {1,2,3,1,2,3,3,2};
        //
        // printOddTimesNum1(arr);
        printOddTimesNum2(arr);
    }
}
